package com.exception.solve;

import java.io.FileReader;
import java.io.IOException;

//测试Throws声明式异常处理
public class Test03 {
    public static void main(String[] args) throws IOException {
        FileReader reader = null;   //finally中要关闭reader，所以要在try外面声明
        try {
            reader = new FileReader("d:/a.txt");
            char c = (char) reader.read();
            char c2 = (char) reader.read();
            char c3 = (char) reader.read();
            System.out.println("" + c + c2 + c3);
        } finally {
            try {
                if (reader!=null) {
                    reader.close();
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
